package gpsdatadecryption;

import java.io.BufferedReader;
import java.io.FileReader;
import java.nio.ByteBuffer;
import java.security.Key;
import java.util.Date;
import java.util.HashMap;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import sun.misc.BASE64Decoder;

/**
 *
 * @author Jonas
 */
public class Main {

    public static void main(String[] args) throws Exception {
        HashMap<Long,Location> returnHash;

        BufferedReader in = new BufferedReader(new FileReader(args[0]));
        String line = "";
        String encrypted = "";
        while((line=in.readLine())!=null){
            if(line.length()==0)
                continue;
            encrypted = encrypted.concat(line);
            if(line.charAt(line.length()-1) == '='){
                returnHash = SecurityManager.decryptRawGPSData(encrypted, "./bestuurderSecret.key");
                for(Long timestamp : returnHash.keySet()){
                    System.out.println("@"+new Date(timestamp)+" - "+returnHash.get(timestamp));
                }
                encrypted = "";
            }
        }
        
    }

}
